<?php
include 'su_log.php';
include '../inc/d.php';
if (isset($_POST['account'])) {
    if (empty(trim($_POST['account']))) {
        echo '账号不能为空';
    } elseif (empty(trim($_POST['passwd']))) {
        echo '密码不能为空';
    } elseif (empty(trim($_POST['passwd2']))) {
        echo '确认不能为空';
    } elseif ($_POST['passwd'] != $_POST['passwd2']) {
        echo '两次密码不一致';
    } else {
        $account = $_POST['account'];
        if (exists('hw_su', "su_account=$account")) {
            echo '账号名' . $account . '已经存在，请重新注册';
        } else {
            $arr_assoc['su_account'] = $account;
            $arr_assoc['su_passwd'] = mm($_POST['passwd'], $account);
            $arr_assoc['su_reg_time'] = time();
            $arr_assoc['su_last_time'] = time();
            $arr_assoc['su_last_ip'] = sprintf('%u', ip2long($_SERVER['REMOTE_ADDR']));
            save('hw_su', $arr_assoc);
            echo '注册成功！';
            header('refresh:3;url=sys_main.php');
        }
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>admin</title>
</head>
<body>
<h3>管理员注册</h3>
<form action="" method="post">
    账号：<input type="text" name="account"><br>
    密码: <input type="password" name="passwd"><br>
    确认密码：<input type="password" name="passwd2">
    <input type="submit" value="提交">
</form>
</body>
</html>
